package cn.jinhe.doc.view.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import cn.jinhe.doc.base.BaseAction;
import cn.jinhe.doc.domain.DeviceMatain;
import cn.jinhe.doc.domain.FixedAssts;
import cn.jinhe.doc.util.QueryHelper;

@Controller
@Scope("prototype")
public class DeviceMatainAction extends BaseAction<DeviceMatain>{
		private Long fixedAsstsId;
		private Long deviceMatainId;
		public Long getDeviceMatainId() {
			return deviceMatainId;
		}
		public void setDeviceMatainId(Long deviceMatainId) {
			this.deviceMatainId = deviceMatainId;
		}
		public String addUI() throws Exception {

			FixedAssts fixedAssts = fixedAsstsService.getById(fixedAsstsId);
			ActionContext.getContext().put("fixedAssts", fixedAssts);
			return "addUI";
		}
/*		public String show() throws Exception{
			
			FixedAssts fixedAssts=fixedAsstsService.getById(fixedAsstsId);
			ActionContext.getContext().put("fixedAssts", fixedAssts);
		
			
			new QueryHelper(DeviceMatain.class, "d")//
			.addCondition("d.fixedAssts=?", fixedAssts)//
			.addOrderProperty("d.matainDate", true)//
			.preparePageBean(deviceMatainService, pageNum, pageSize);

			
			return "toFixedAsstsShow";
		}*/
		public String delete() throws Exception {
			deviceMatainService.delete(deviceMatainId);
			
			return "toFixedAsstsShow";
		}
		
		public String add() throws Exception {

			// 封装
			// >> 表单字段，已经封装了title, content
			// model.setTitle(title);
			// model.setContent(content);
			
			
			model.setFixedAssts(fixedAsstsService.getById(fixedAsstsId));
			
//			model.setTopic(topicService.getById(topicId));
			// >> 当前信息
//			model.setAuthor(getCurrentUser()); // 当前用户
//			model.setIpAddr(ServletActionContext.getRequest().getRemoteAddr());
//			model.setPostTime(new Date()); // 当前时间
			// 保存
			deviceMatainService.save(model);
			return "toFixedAsstsShow";
		}
		public Long getFixedAsstsId() {
			return fixedAsstsId;
		}

		public void setFixedAsstsId(Long fixedAsstsId) {
			this.fixedAsstsId = fixedAsstsId;
		}
	
	
}
